# 池化操作：池化核遍历输入的张量输出值，池化操作会简化输入张量
# 最大池化：池化核遍历时会得到对应部分的最大值
import torch
import torch.nn as nn
import torchvision
from torch.nn import MaxPool2d
from torch.utils.data import DataLoader


class Module(nn.Module):
    def __init__(self):
        super(Module,self).__init__()
        self.maxpool2d = MaxPool2d(kernel_size=(3, 3), ceil_mode=True)

    def forward(self, x):
        return self.maxpool2d(x)


# data_test = torchvision.datasets.CIFAR10("./dataset", train=False, transform=torchvision.transforms.ToTensor())
# datas = DataLoader(data_test,batch_size=64,shuffle=True)
input_ = torch.tensor([[1,2,0,3,1],
                       [0,1,2,3,1],
                       [1,2,1,0,0],
                       [2,3,1,2,0],
                       [1,4,2,1,0]],dtype=torch.float32)
input_ = torch.reshape(input_,[-1,1,5,5])
MyModule = Module()
output = MyModule(input_)
print(output)
